package gui;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTextField;

import model.Model;

public class RemovePanel extends JPanel implements ActionListener{

	private static final long serialVersionUID = 1L;
	Model model;
	TopPanel parent;
	
	JButton removeNodeButton;
	JTextField nodeNumberField;

	public RemovePanel(Model model, TopPanel parent) {
		this.model = model;
		this.parent = parent;
		setLayout(new BorderLayout());
		removeNodeButton = new JButton("Remove Node");
		nodeNumberField = new JTextField(4);
		
		removeNodeButton.addActionListener(this);
		
		add(removeNodeButton, BorderLayout.WEST);
		add(nodeNumberField, BorderLayout.EAST);
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		String stringInput = nodeNumberField.getText();
		System.out.println(stringInput);
		int nodeNumber;
		try{
			nodeNumber = Integer.parseInt(stringInput);
			model.removeNode(nodeNumber);
		} catch(Exception e) {
			
		}
		
	}
}
